<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>客户管理</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="汽车租赁系统">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="${(cusId.custormerName)}" placeholder=""
                       id="custormerName" name="name">
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="${(cusId.custormerPhone)}" placeholder=""
                       id="custormerPhone"
                       name="mobile">
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="${(cusId.custormerIdCard)}" placeholder=""
                       id="custormerIdCard"
                       name="mobile">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>原因类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="${(cusId.custormerStateRemark)}" placeholder=""
                       id="custormerStateRemark" name="reasontype">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input id="saveBtn" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
                <input id="cancelBtn" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;取消&nbsp;&nbsp;""/>
            </div>
        </div>
    </form>
</article>

<#include "include/_footer.html">

<script>

    var editBlackList = function () {
        if (!check().form()) {
            return;
        }

        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: '/update',
            data: {
				custormerId:${(cusId.custormerId?c)!},
                custormerName: $("#custormerName").val(),
                custormerPhone: $("#custormerPhone").val(),
                custormerIdCard: $("#custormerIdCard").val(),
                custormerStateRemark: $("#custormerStateRemark").val()
            },
            success: function (result) {
				if (result=='1'){
					parent.layer.msg("已经成功修改记录" , {icon: 1});
					var index = parent.layer.getFrameIndex(window.name);
					parent.getBackList();
					parent.layer.close(index);
				}else {
					parent.layer.msg("修改记录失败" , {icon: 5});
				}
            }
        });

    };

    $("#saveBtn").click(function () {
		editBlackList();
    });

    $("#cancelBtn").click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.getBackList();
        parent.layer.close(index);
    });


    //非空校验
    function check() {
        return $("#form-admin-add").validate({
            rules: {
                custormerName: {
                    required: true
                },
                custormerPhone: {
                    required: true
                },
                custormerIdCard: {
                    required: true
                },
                custormerStateRemark: {
                    required: true
                }

            },

            message: {
                custormerName: {
                    required: ""
                },
                custormerPhone: {
                    required: ""
                },
                custormerIdCard: {
                    required: ""
                },
                custormerStateRemark: {
                    required: ""
                }
            }
        });
    }
</script>

</body>
</html>